<include file="Public/min-header"/>

<style>
   .modal {
      display: none;
      position: fixed;
      z-index: 9999;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background-color: rgba(0, 0, 0, 0.8);
   }
 
   .modal-image {
      display: block;
      max-width: 90%;
      max-height: 90%;
      margin: auto;
      margin-top: 5%;
   }
</style>




<div class="wrapper">
    <include file="Public/breadcrumb"/>
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <nav class="navbar navbar-default">
                        <div class="collapse navbar-collapse">
                            <div class="navbar-form pull-right margin">
                                <!--
                                  <if condition="$order['order_status'] lt 2">
                                     <a href="{:U('Admin/order/edit_order',array('order_id'=>$order['order_id']))}" data-toggle="tooltip" title="" class="btn btn-primary" data-original-title="编辑">修改订单</a>
                                  </if>
                                  <if condition="($split eq 1) and ($order['order_status'] lt 2)">
                                     <a href="{:U('Admin/order/split_order',array('order_id'=>$order['order_id']))}" data-toggle="tooltip" title="" class="btn btn-primary" data-original-title="编辑">拆分订单</a>
                                  </if>
                                -->
                                <a href="{:U('Order/order_print',array('order_id'=>$order['order_id']))}"
                                   target="_blank" data-toggle="tooltip" title="" class="btn btn-primary"
                                   data-original-title="打印订单">
                                    <i class="fa fa-print"></i>打印订单
                                </a>
                                <a href="javascript:history.go(-1)" data-toggle="tooltip" title=""
                                   class="btn btn-default" data-original-title="返回"><i class="fa fa-reply"></i></a>
                            </div>
                        </div>
                    </nav>

                    <!--新订单列表 基本信息-->
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h3 class="panel-title text-center">基本信息</h3>
                        </div>
                        <div class="panel-body">
                            <table class="table table-bordered">
                                <tbody>
                                <tr>
                                    <td> ID:</td>
                                    <td>单号:</td>
                                    <td>接单人:</td>
                                    <td>任务:</td>
                                
                                    <td>应付:</td>
                                    <td>状态:</td>
                                    <td>创建时间:</td>
                                    <td>提交时间:</td>
                          
                                    <td>图片:</td>
                                </tr>
                                <tr>
                                    <td>{$order.order_id}</td>
                                    <td>{$order.order_sn}</td>
                                    <td><a href="#" target="_blank">{$userInfo.nickname}:{$userInfo.mobile}</a></td>
                                    <td><a href="#">{$goodsInfo.goods_name}</a></td>
                                  
                                    <td>{$order.goods_price}</td>
                                    <td id="order-status">{$order_status[$order[order_status]]}
                                   
                                    </td>
                                    <td>{$order.add_time|date='Y-m-d H:i',###}</td>
                                    <td>{$order.shipping_time|date='Y-m-d H:i',###}</td>
                          
                                    <td> 图片
                                    </td>
                                </tr>

                                </tbody>
                            </table>
                        </div>
                    </div>
                    <!--任务信息-->
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h3 class="panel-title text-center">任务信息</h3>
                        </div>
                        <div class="panel-body">
                            <table class="table table-bordered">
                                <tbody>
                                <tr>
                                    <td>任务:</td>
                                    <td>发起人:</td>
                                    <td>金额:</td>
                                    <td>类型:</td>
                                    <td>任务结束时间:</td>
                                    <td>任务提交过期时间:</td>
                                </tr>
                                <tr>
                                    <td>{$goodsInfo.goods_name}</td>
                                    <td>{$orderGoodsStoreInfo.nickname}:{$orderGoodsStoreInfo.mobile}</td>
                                    <td>{$orderGoodsStoreInfo.shop_price}</td>
                                    <td>
                                        {$orderGoodsStoreInfo.type}
                                    </td>
                                    <td>
                                        {$orderGoodsStoreInfo.endtime}
                                    </td>
                                    <td>
                                        
                                        <if condition="$orderGoodsStoreInfo.overdue_time neq ''">
                                            {$orderGoodsStoreInfo.overdue_time}
                                            <else/>
                                            长期有效
                                        </if>
                                    </td>

                                </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <!--新订单列表 商品信息-->

                    <!--新订单列表 操作记录信息-->
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            <h3 class="panel-title text-center">提交记录</h3>
                        </div>
                        <div class="panel-body">
                            <table class="table table-bordered">
                                <thead>
                                <tr>
                                    <td class="text-center"></td>
                                </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                        <volist name="ordertjInfo" id="log">
                                            <td class="text-center">
                                                <image src="{$log.img}"  style="width:4rem;height:4rem;" alt="图像" onclick="showModal(this)">
                                            </td>
                                        </volist>
                                    </tr>
                                </tbody>
                            </table>
                        </div>
                    </div>
                     <div class="panel panel-default">
                         
                         <div class="navbar-form pull-right margin">
          
                                <a href="javascript:void(0);"
                                    title="" class="btn btn-primary"
                                   data-original-title="审核通过" onclick="dopass(this)"  >
                                    <i class="fa fa-print"></i>通过
                                </a>
                                <!--<a href="javascript:void(0);"-->
                                <!--   title="" class="btn btn-danger"-->
                                <!--   data-original-title="审核通过" onclick="dorefuse(this)">-->
                                <!--    <i class="fa fa-print"></i>拒绝-->
                                <!--</a>-->
                                
                                <button data-method="setTop" class="layui-btn">拒绝</button>
                                
                                
                                
                                <input type="hidden" value="{$order.order_id}" id="orderId" >
                            </div>
                     </div>
                </div>
            </div>
        </div>
    </section>
</div>

<!--模仿bootstrap的模态框-->
<div id="motaikunag" style="display: none;">
    <div>
        <div></div>
        <div>
           <form class="layui-form" action=""> 
            
              <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">拒绝理由</label>
                <div class="layui-input-block">
                  <textarea placeholder="请填写拒绝理由" class="layui-textarea" name="desc" id="refuseRemake"></textarea>
                </div>
              </div>
           

             <div class="layui-form-item">
                <div class="layui-input-block">
                  <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1" onclick="refuseSubmitAuditing(this)" >提交</button>
                  <button type="reset" class="layui-btn layui-btn-primary" onclick="closeAuditing(this)">关闭</button>
                </div>
            </div>
         </form>  
        </div>
       
        
    </div>
</div>



</body>

<div id="modal" class="modal" onclick="hideModal()">
  <img id="modal-image" class="modal-image">
</div>
 
<script>
   function showModal(image) {
      var modal = document.getElementById("modal");
      var modalImage = document.getElementById("modal-image");
      modal.style.display = "block";
      modalImage.src = image.src;
   }
 
   function hideModal() {
      var modal = document.getElementById("modal");
      modal.style.display = "none";
   }
   
   //审核拒绝提交
   function refuseSubmitAuditing(e){
       
       let refuseRemake = $("#refuseRemake").val();
       
       let orderId = $("#orderId").val();
       let status ="1";
       let url ="{:U('Admin/Order/renwuRefuse')}";
       let data={};
       
        data.order_id =orderId;
        data.status =status;
        data.remake = refuseRemake;
        duRes(url,data);
       
       
   }
   
   
    function closeAuditing(e){
       layer.closeAll();
   }
   
   
   
   
</script>

<script>
    
    layui.use('layer', function(){ //独立版的layer无需执行这一句
        var $ = layui.jquery, layer = layui.layer; //独立版的layer无需执行这一句

        var active = {
            
            setTop: function(){
                  //配置一个透明的询问框
                  var that = this;
                //多窗口模式，层叠置顶
                layer.open({
                    type: 1 //此处以iframe举例
                    ,title: '任务拒绝'
                    ,area: ['390px', '260px']
                    ,shade: 0
                    ,maxmin: true
                    ,offset: [ //为了演示，随机坐标
                        Math.random()*($(window).height()-300)
                        ,Math.random()*($(window).width()-390)
                    ]
                    ,content: $('#motaikunag')//打开的内容

                    // ,btn: ['是', '否'] //只是为了演示
                    ,yes: function(){
                       
                        
                        console.log("1");
                         let orderId = $("#orderId").val();
                         let status ="1";
                         let url ="{:U('Admin/Order/renwuRefuse')}";
                
                        let data ={};
                            data.order_id =orderId;
                            data.status =status;
                         duRes(url,data);
                        
                        
                        
                    }
                    ,btn2: function(){
                        layer.closeAll();
                        console.log("2");
                    }

                    ,zIndex: layer.zIndex //重点1
                    ,success: function(layero, index){
                        layer.setTop(layero); //重点2. 保持选中窗口置顶
                        console.log("layero",layero);
                        console.log("index",index);
                        //记录索引，以便按 esc 键关闭。事件见代码最末尾处。
                        layer.escIndex = layer.escIndex || [];
                        layer.escIndex.unshift(index);
                        //选中当前层时，将当前层索引放置在首位
                        layero.on('mousedown', function(){
                            var _index = layer.escIndex.indexOf(index);
                            if(_index !== -1){
                                layer.escIndex.splice(_index, 1); //删除原有索引
                            }
                            layer.escIndex.unshift(index); //将索引插入到数组首位
                        });
                    }
                    ,end: function(){
                        //更新索引
                        if(typeof layer.escIndex === 'object'){
                            layer.escIndex.splice(0, 1);
                        }
                    }
                });
                  
            }
            
            
        }
        
        $('.layui-btn').on('click', function(){
            var othis = $(this), method = othis.data('method');
            active[method] ? active[method].call(this, othis) : '';
        });
        
        
        
        
        
        
        
        
        
    })
    
    
    
    
</script>



<script>
    function dorefuse(obj){

         let orderId = $("#orderId").val();
         let status ="1";
         let url ="{:U('Admin/Order/renwuRefuse')}";

        let data ={};
            data.order_id =orderId;
            data.status =status;
         duRes(url,data);
     }

     function dopass(obj){
         let orderId = $("#orderId").val();
         let status ="5";
         let url ="{:U('Admin/Order/renwuPass')}";
         let data ={};
             data.order_id =orderId;
             data.status =status;
         duRes(url,data);
     }

     function duRes(url,data){
         $.post(url,data,function(res){
                if(res.status==1){
                    layer.msg('操作成功', {icon: 1});
                    window.location.href = document.referrer;
                }else{
                    layer.msg(res.msg, {icon: 1});
                }
                
         },"json");


     }




    function pay_cancel(obj) {
        var url = $(obj).attr('data-url') + '/' + Math.random();
        layer.open({
            type: 2,
            title: '退款操作',
            shadeClose: true,
            shade: 0.8,
            area: ['45%', '50%'],
            content: url,
        });
    }

    //取消付款
    function pay_callback(s) {
        if (s == 1) {
            layer.msg('操作成功', {icon: 1});
            layer.closeAll('iframe');
            location.href = location.href;
        } else {
            layer.msg('操作失败', {icon: 3});
            layer.closeAll('iframe');
            location.href = location.href;
        }
    }

    // 弹出退换货商品
    function selectGoods2(order_id) {
        var url = "/index.php?m=Admin&c=Order&a=get_order_goods&order_id=" + order_id;
        layer.open({
            type: 2,
            title: '选择商品',
            shadeClose: true,
            shade: 0.8,
            area: ['60%', '60%'],
            content: url,
        });
    }

    // 申请退换货
    function call_back(order_id, goods_id) {
        var url = "/index.php?m=Admin&c=Order&a=add_return_goods&order_id=" + order_id + "&goods_id=" + goods_id;
        location.href = url;
    }
</script>
</html>